package io;

import java.io.*;
import java.nio.charset.StandardCharsets;
import java.util.Scanner;

public class Test3 {
    public static void main(String[] args) throws IOException {
        FileOutputStream fos = new FileOutputStream("note.txt",true);
        OutputStreamWriter osw = new OutputStreamWriter(fos, StandardCharsets.UTF_8);
        BufferedWriter bw = new BufferedWriter(osw);
        //
        PrintWriter pw = new PrintWriter(bw,true);
        Scanner s = new Scanner(System.in);
        String str = "";
        System.out.println("开始输入内容，单独输入exit退出");
        while(!"exit".equalsIgnoreCase(str=s.next())){
            /**
             * 当pw开启了自动行刷新后，每当我们调用一次println方法后就会自动flush
             */
            pw.println(str);
        }
        pw.close();
        System.out.println("结束");
    }
}
